<?php
	
	//pagina
	function xhtml($fHead, $fBody, $propBody='')
	{
		return 
		"
<!--DOCTYPE-->
<!--DTD (Document Type Definition), dichiara ai Browser i SW di validazione--> 
<!--DTD Strinct, ogni elemento usato per il suo scopo-->
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>

<!--HTML-->
<!--NAMESPACE, collezione di nomi e attributi di uno specifico DDT-->
<html xmlns='http://www.w3.org/1999/xhtml' lang='en' xml:lang='en'>
	
<!--HEAD-->	
<head>
".$fHead."	
</head>
		
<!--BODY-->		
<body ".$propBody.">
".$fBody."
</body>
			
</html>
		";
	}

	/*
	 * Creazione head: title, fMetatag, fCss, fJavascript ...
	 */
	function fHead($title, $fMetatag, $fCss, $fJavascript)
	{
		return 
"
<!--TITLE-->
<title>$title</title>
				
<!--METATAG-->
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'> <!-- default -->
".$fMetatag."

<!--CSS-->
<link rel='stylesheet' type='text/css' href='css/reset.css' /> <!--Reset di Eric Meyer-->
".$fCss."		
				
<!--JAVASCRIPT, JQUERY-->
".$fJavascript;
	}
	/*
	 * Creazione lista di metatag
	 * Input: array di array $arrArrMetatag, sono coppie di name e content. Es. [['author','Davide Ragazzi'],['description','sitoweb di proposte'],['keywords','proposta,soluzione']]
	 */
	function fMetatag($arrArrMetatag)
	{
		$listaMetatag='';
		for ($i = 0; $i < count($arrArrMetatag); $i++)
			$listaMetatag = $listaMetatag.fMetatagSingolo($arrArrMetatag[$i][0],$arrArrMetatag[$i][1]);
		return $listaMetatag;
	}
	
	/*
	 * Creazione metatag
	 * Input: $name, $content  
	 */
	function fMetatagSingolo($name, $content)
	{
		return 
"
<meta name='$name' content='$content'>";
	}
	/*
	 * Creazione lista di css
	 * Input: $arrCss, sono gli href. Es. ['css/font.css', 'css/style.css']
	 */
	function fCss($arrCss)
	{
		$listaCss = '';
		for($i=0;$i<count($arrCss);$i++)
			$listaCss = $listaCss.
"
<link rel='stylesheet' type='text/css' href='$arrCss[$i]' />";
		return $listaCss;
	}
	/*
	 * Creazione lista file Javascript e Jquery
	 * Input: $arrJavascript, sono gli src. Es. ['js/placeholderBrowser.js', 'js/controllo.js']
	 */
	function fJavascript($arrJavascript)
	{
		$listaJavascript = '';
		for($i=0;$i<count($arrJavascript);$i++)
			$listaJavascript = $listaJavascript.
"
<script type='text/javascript' src='$arrJavascript[$i]'></script>";	
		return $listaJavascript;
	}		
	
	/*
	 * Creazione fBody
	 */	
	function fBody($listaNodiBody)
	{	
		return $listaNodiBody;		
	}
	
	//intestazione
	function h($class, $idname, $testo, $tab='', $size = 1)
	{
		$head = 'h' . $size;
		$risultato = 
"
 ".$tab."<$head class='$class' id='$idname' name='$idname'>" . $testo . "</$head>";
		return $risultato;
	}	
	//div
	function div($class, $idname, $corpo, $tab='', $prop='')
	{
		return 
" 
 ".$tab."<div class='$class' id='$idname' name='$idname' ".$prop.">" . $corpo . "
 ".$tab."</div>";
	}
	
	
	//link
	function hlink($class, $idname, $href, $label, $tab='')
	{
		return 
"
 ".$tab."<a class='$class' id='$idname' name='$idname' href='$href' >" . $label . "</a>";
	}
	
	//form
	function form($class, $idname, $action, $corpo, $tab='', $enctype = "application/x-www-form-urlencoded")
	{
		$testa = 
"
 ".$tab."<form class='$class' id='$idname' name='$idname' action='$action' enctype='$enctype' method='post'>";
		$coda = 
"
 ".$tab."</form>";
		return $testa . $corpo . $coda;
	}
	
	//casella di testo
	function text($class, $idname, $tab='', $placeholder='', $value='')
	{
		return 
"
 ".$tab."<input type='text' class='$class' id='$idname' name='$idname' placeholder='$placeholder' value='$value' />";
	}
	
	//password
	function password($class, $idname, $tab='')
	{
		return 
"
 ".$tab."<input type='password' class='$class' id='$idname' name='$idname' />";
	}
	
	//select
	function select($class, $idname, $corpo, $tab='')
	{
		$testa = 
"
 ".$tab."<select class='$class' id='$idname' name='$idname'>";
		$coda = 
"
 ".$tab."</select>";
		return $testa . $corpo . $coda;
	}
	
	//option select
	function optionSelect($value, $corpo,$tab='',$prop='')
	{
		return
		"
 ".$tab."<option value='$value' " .$prop.">" . $corpo . "</option>";
	}
	
	//file/immagine
	function inputFile($class, $idname, $tab='')
	{
		return 
"
 ".$tab."<input type='file' class='$class' id='$idname' name='$idname' />";
	}
	
	//pulsante
	function submit($class, $idname, $tab='', $value = 'Invia', $prop='')
	{
		return 
		"
 ".$tab."<input type='submit' class='$class' id='$idname' name='$idname' value='$value' ".$prop."/>";
	}
	
	//interruzioni
	function br($n=1)
	{
		$codice = '';
		for($i=1; $i<=$n; $i++)
			$codice .= '<br/>';
			return $codice;
	}
	
	//label
	function label($for,$idname,$label,$tab)
	{
		return 
"
 ".$tab."<label for='$for' id='$idname'>" . $label . "</label>";
	}
	
	//textarea
	function textarea($class, $idname, $tab='', $placeholder='',$value='')
	{
		return 
"
 ".$tab."<textarea class='$class' id='$idname' name='$idname' placeholder='$placeholder' value='$value'>$value</textarea>";
	}
	
	//radio button
	function radiobutton($class, $idname, $value, $tab='',$prop='')
	{
		return 
"
 ".$tab."<input type='radio' class='$class' id='$idname' name='$idname' value='$value'".$prop.">";
	}
	
	//checkbox
	function checkbox($class, $idname, $value, $tab='')
	{
		return
		"
 ".$tab."<input type='checkbox' class='$class' id='$idname' name='$idname' value='$value'>";
	}
	
	//img
	function img($class, $idname, $src, $height, $width, $alt='', $tab='')
	{
		return 
"
 ".$tab."<img class='$class' id='$idname' name='$idname' src='$src' height='$height' width='$width'  alt='$alt'/>";
	}

?>